GBML manual / 3D

view3d_move

Moves the camera forward (negative is back) and to its right (negative is left) by that many pixels, stopping at walls. True when it moved at all.

Game Boy: not available

Game Boy Color: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

view3d_move(forward, side) -> bool

Arguments

NameType
forwardreal
sidereal

Returns

bool

Description

Moves the camera forward pixels the way it faces (a negative number moves back) and side pixels to its right (a negative number moves left), stopping at walls. It answers true when the camera moved at all.

The two directions are tried one after the other, so the camera slides along a wall instead of sticking to it. Walls are the solid tiles and the edges of the room, kept view3d_radius pixels away.

Call it once a frame with the speed you want, in pixels per frame. 1.5 is a walk.

Example

// Step event: up and down walk, left and right turn.
if (action_held(up)) { view3d_move(1.5, 0); }
if (action_held(down)) { view3d_move(-1.5, 0); }
if (action_held(left)) { view3d_turn(3); }
if (action_held(right)) { view3d_turn(-3); }

The camera walks and turns, and stops at every wall.

On the GBA

The two directions are tried one after the other, so the camera slides along a wall instead of sticking to it. Call it once a frame with the speed you want in pixels per frame, for example view3d_move(1.5, 0). Walls are the solid tiles and the edges of the room.

See also: Collision in 3D3D viewview3d_turnview3d_radiusview3d_camera